/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.anhanguera.tcc.model;

import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Diego
 */
@Entity
@Table(name = "tb_item_comprovante_entrega")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ItemComprovanteEntrega.findAll", query = "SELECT i FROM ItemComprovanteEntrega i"),
    @NamedQuery(name = "ItemComprovanteEntrega.findByCodItemContrato", query = "SELECT i FROM ItemComprovanteEntrega i WHERE i.itemComprovanteEntregaPK.codItemContrato = :codItemContrato"),
    @NamedQuery(name = "ItemComprovanteEntrega.findByCodComprovanteEntrega", query = "SELECT i FROM ItemComprovanteEntrega i WHERE i.itemComprovanteEntregaPK.codComprovanteEntrega = :codComprovanteEntrega"),
    @NamedQuery(name = "ItemComprovanteEntrega.findByQtFaturar", query = "SELECT i FROM ItemComprovanteEntrega i WHERE i.qtFaturar = :qtFaturar"),
    @NamedQuery(name = "ItemComprovanteEntrega.findByVlFaturar", query = "SELECT i FROM ItemComprovanteEntrega i WHERE i.vlFaturar = :vlFaturar")})
public class ItemComprovanteEntrega implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected ItemComprovanteEntregaPK itemComprovanteEntregaPK;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Column(name = "QT_FATURAR")
    private BigDecimal qtFaturar;
    @Basic(optional = false)
    @NotNull
    @Column(name = "VL_FATURAR")
    private BigDecimal vlFaturar;
    @JoinColumn(name = "COD_COMPROVANTE_ENTREGA", referencedColumnName = "ID_COMPROVANTE_ENTREGA", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private ComprovanteEntrega comprovanteEntrega;
    @JoinColumn(name = "COD_ITEM_CONTRATO", referencedColumnName = "ID_ITEM_CONTRATO", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private ItemContrato itemContrato;

    public ItemComprovanteEntrega() {
    }

    public ItemComprovanteEntrega(ItemComprovanteEntregaPK itemComprovanteEntregaPK) {
        this.itemComprovanteEntregaPK = itemComprovanteEntregaPK;
    }

    public ItemComprovanteEntrega(ItemComprovanteEntregaPK itemComprovanteEntregaPK, BigDecimal qtFaturar, BigDecimal vlFaturar) {
        this.itemComprovanteEntregaPK = itemComprovanteEntregaPK;
        this.qtFaturar = qtFaturar;
        this.vlFaturar = vlFaturar;
    }

    public ItemComprovanteEntrega(int codItemContrato, int codComprovanteEntrega) {
        this.itemComprovanteEntregaPK = new ItemComprovanteEntregaPK(codItemContrato, codComprovanteEntrega);
    }

    public ItemComprovanteEntregaPK getItemComprovanteEntregaPK() {
        return itemComprovanteEntregaPK;
    }

    public void setItemComprovanteEntregaPK(ItemComprovanteEntregaPK itemComprovanteEntregaPK) {
        this.itemComprovanteEntregaPK = itemComprovanteEntregaPK;
    }

    public BigDecimal getQtFaturar() {
        return qtFaturar;
    }

    public void setQtFaturar(BigDecimal qtFaturar) {
        this.qtFaturar = qtFaturar;
    }

    public BigDecimal getVlFaturar() {
        return vlFaturar;
    }

    public void setVlFaturar(BigDecimal vlFaturar) {
        this.vlFaturar = vlFaturar;
    }

    public ComprovanteEntrega getComprovanteEntrega() {
        return comprovanteEntrega;
    }

    public void setComprovanteEntrega(ComprovanteEntrega comprovanteEntrega) {
        this.comprovanteEntrega = comprovanteEntrega;
    }

    public ItemContrato getItemContrato() {
        return itemContrato;
    }

    public void setItemContrato(ItemContrato itemContrato) {
        this.itemContrato = itemContrato;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (itemComprovanteEntregaPK != null ? itemComprovanteEntregaPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ItemComprovanteEntrega)) {
            return false;
        }
        ItemComprovanteEntrega other = (ItemComprovanteEntrega) object;
        if ((this.itemComprovanteEntregaPK == null && other.itemComprovanteEntregaPK != null) || (this.itemComprovanteEntregaPK != null && !this.itemComprovanteEntregaPK.equals(other.itemComprovanteEntregaPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.anhanguera.tcc.model.ItemComprovanteEntrega[ itemComprovanteEntregaPK=" + itemComprovanteEntregaPK + " ]";
    }

}
